<?php
namespace app\command;

use app\model\OrderAftersalesModel;
use app\model\OrderItemsModel;
use app\model\OrderLogisticsModel;
use app\model\OrderReviewsModel;
use app\model\OrdersModel;
use app\model\ProductsModel;
use app\model\StatisticsModel;
use think\console\Command;
use think\console\Input;
use think\console\Output;

class UpdateProductNum extends Command
{

    protected function configure()
    {
        $this->setName('更新物流轨迹')
            ->setDescription('批量处理订单的物流信息');
    }

    protected function execute(Input $input, Output $output)
    {
        // 执行你的脚本任务代码

//        $orderItemModel = new OrderItemsModel();
//        $productsModel = new ProductsModel();
//        $where =[];
//        $list = $orderItemModel->getList($where,1,999999);
//        if($list) {
//            foreach ($list as $one){
//                $productsModel->incrProductSalesNum($one['product_id'],$one['spec_num']);
//            }
//        }


//            $orderReviewsModel = new OrderReviewsModel();
//            $productsModel = new ProductsModel();
//            $where =[];
//            $list = $orderReviewsModel->getList($where,1,999999);
//            if($list) {
//                foreach ($list as $one){
//                    $productsModel->incrProductReviewsNum($one['product_id'],1);
//                }
//            }


        $orderAftersalesModel = new OrderAftersalesModel();
        $ordersModel = new OrdersModel();
        $where =[];
        $list = $orderAftersalesModel->getList($where,1,999999);
        foreach ($list as $one){
            $ordersModel->updateOrderAftersaleStatus($one['p_order_id'],$one['aftersale_status']);
        }


    }
}